@section('content')
<div class="am-cf am-padding">
   <div class="am-fl am-cf">
      <a href="{{URL::route('story')}}"><strong class="am-text-primary am-text-lg">The Stories</strong></a> / <small>添加</small>
   </div>
</div>
<form class="am-form am-form-horizontal" id="storyForm" name="storyForm" enctype="multipart/form-data"
	method="post" action="{{URL::route('story.add')}}">
  <div class="am-form-group">
    <label for="title" class="am-u-sm-2 am-form-label">标题</label>
    <div class="am-u-sm-5">
      <input type="text" id="title" name="title" placeholder="输入标题"
      	data-rules="required|max_length[64]" class="validate" data-display="标题"
      	value="{{isset($story) ?  $story->title : ''}}">
    </div>
    <p class="am-u-sm-5 help-block"></p>
  </div>
  <div class="am-form-group">
    <label for="title" class="am-u-sm-2 am-form-label">副标题</label>
    <div class="am-u-sm-5">
      <input type="text" id="subtitle" name="subtitle" placeholder="输入副标题"
      	data-rules="required|max_length[64]" class="validate" data-display="副标题"
      	value="{{empty($story) ? '' : $story->subtitle}}">
    </div>
    <p class="am-u-sm-5 help-block"></p>
  </div>
  
  <div class="am-form-group">
    <label for="title" class="am-u-sm-2 am-form-label">摘要</label>
    <div class="am-u-sm-5">
      <textarea rows="" cols="" id="summary" name="summary" placeholder="输入摘要"
      data-rules="required|max_length[128]" class="validate" data-display="摘要">{{empty($story) ? '' : $story->summary}}</textarea>
    </div>
    <p class="am-u-sm-5 help-block"></p>
  </div>
  
  <div class="am-form-group">
    <label for="title" class="am-u-sm-2 am-form-label">图片</label>
    <div class="am-u-sm-5">
    @if (empty($story))
	     <input type="file" id="image" name="image" placeholder="输入图片"
      	data-rules="required" class="validate" data-display="副标题">
	@else
	    <input type="file" id="image" name="image" placeholder="输入图片">
	@endif
    
    </div>
    <p class="am-u-sm-5 help-block"></p>
  </div>

   <div class="am-form-group">
	    <label for="content" class="am-u-sm-2 am-form-label">内容</label>
	    <div class="am-u-sm-9">
	      <textarea id="content" name="content" placeholder="输入内容"
	      	data-rules="required" class="validate" data-display="内容">{{empty($story) ? '' : $story->content}}</textarea>
	    </div>
	    <p class="am-u-sm-1 help-block"></p>
   </div>

  <div class="am-form-group">
    <div class="am-u-sm-10 am-u-sm-offset-2">
      <button type="submit" class="am-btn am-btn-primary">添加</button>
    </div>
  </div>
  <input type="hidden" name="id" value="{{empty($story) ? 0 : $story->id}}">
</form>
@stop

@section('script')
{{ HTML::script('assets/js/ueditor/ueditor.config.js') }}
{{ HTML::script('assets/js/ueditor/ueditor.all.min.js') }}
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
{{ HTML::script('assets/js/ueditor/lang/zh-cn/zh-cn.js') }}
<script type="text/javascript">
$(function () {
	var ue = UE.getEditor('content',{
		    serverUrl : "{{URL::route('ueditor')}}",
		    initialFrameHeight : 320,
			toolbars: [
		           ['fullscreen', 'source', 'undo', 'redo', 'bold','italic','link','simpleupload','insertvideo',
			         'imagenone', //默认
		            'imageleft', //左浮动
		            'imageright', //右浮动
		            'imagecenter', //居中
		            'drafts', // 从草稿箱加载
					]
		       ],
		});
	$("#storyForm").validate();
});
</script>
@stop
